package com.wxg.study.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    private CounterService counterService;

    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }

    @RequestMapping("/foo")
    public String foo(@RequestParam(name = "xx") String xx) {
        counterService.increment("wxg.foo.count");
        return "hello " + xx;
    }

    @RequestMapping("/hi/{name}")
    public String hi(@PathVariable("name") String name) {
        return "Hi " + name;
    }
}
